package com.boboPlanet.user.mq.consumer;

import com.boboPlanet.comm.context.LoginUserContext;
import com.boboPlanet.comm.entity.dto.PlanetMqMsg;
import com.boboPlanet.comm.entity.po.LoginUserInfoPO;
import com.boboPlanet.comm.rabbitmq.RabbitMqRoutingConfig;
import com.boboPlanet.comm.rabbitmq.consume.PlanetConsumeListener;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/3/23
 **/
@Slf4j
@Component
public class UserLoginMqHandler implements PlanetConsumeListener {

    @Override
    public String queue() {
        return null;
    }

    @Override
    public String exchange() {
        return null;
    }

    @Override
    public String routingKey() {
        return null;
    }

    @Override
    public String ackMode() {
        return null;
    }

    @Override
    @RabbitListener(queues = RabbitMqRoutingConfig.USER_LOGIN_MQ)
    public void receive(Message message, Channel channel, long tag) {
        String dataStr = new String(message.getBody());

        PlanetMqMsg mqData = PlanetMqMsg.deserialize(dataStr);

        LoginUserInfoPO infoPO = LoginUserContext.getLoginUserInfoPO();

        log.info("receive user login msg ==> {}",mqData);
    }
}
